function hn_validator(formname)
{
    isfocus = false;
    isvalid = true;
  $('input[hn-isval="true"]').each(function(e){
      if(this.getAttribute('hn-val-data') !== null)
      {

          validdata = (this.getAttribute('hn-val-data'));
          value = this.value;
          items = validdata.split("|");
          $(this).removeClass('hn-error');
          for(i in items)
          {
               textdata = items[i];
               if (textdata == 'required')
                  {
                      if(value == null || value == undefined || value.trim() == ""){
                          $(this).addClass('hn-error');
                          if(!isfocus){this.focus();isfocus=true;}
                          isvalid =false;
                      }
                  }
               else if(textdata.indexOf('min:')>=0)
                {
                    min =parseInt(textdata.replace("min:",''));
                    if(value.length < min){
                        $(this).addClass('hn-error');
                        if(!isfocus){this.focus();isfocus=true;}
                        isvalid =false;
                    }
                }
               else if(textdata.indexOf('max:')>=0)
                {
                       max =parseInt(textdata.replace("max:",''));
                       if(value.length > max){
                           $(this).addClass('hn-error');
                           if(!isfocus){this.focus();isfocus=true;}
                           isvalid =false;
                       }
               }
               else if(textdata.indexOf('compare:')>=0)
               {
                   remote =textdata.replace("compare:",'');
                   if ($(remote).val() != value){
                       $(this).addClass('hn-error');
                       if(!isfocus){this.focus();isfocus=true;}
                       isvalid =false;
                   }
               }
               else if(textdata.indexOf('remote:')>=0)
               {
                   remote =textdata.replace('remote:','');
                   remote =remote.replace('_base_',root);
               }

          }
      }
  });
    return isvalid;
}
